/*
 * @Date: 2023-03-21 15:55:31
 * @LastEditTime: 2023-03-28 16:10:03
 * @FilePath: /hash-guess-game/src/api/module/drawCoin.ts
 * 介绍:
 */
import toast from "@@/components/rework/toast";
import { defaHttp, ApiRes, ApiReturn, Paging } from "../index";

/**申请提币 */
export async function apiDrawCoin(
  data: DrawCoin.Req
): ApiReturn<ApiRes<DrawCoin.Res>> {
  const res = await defaHttp.post<ApiRes<DrawCoin.Res>>(
    "/wallet/withdraw",
    data,
    { mode: ["showLoading", "showError"] }
  );
  if (res.code !== 200) return;
  toast.success(res.data);
  return res;
}
/**申请提币 */
export namespace DrawCoin {
  export interface Req {
    coin_id: Id;
    number: number;
    /**最低8位，最多16位，做好限制 */
    // password: string;
  }
  export type Res = string;
}

/**提币列表 */
export async function apiDrawCoinList(
  data: Paging.Req
): ApiReturn<Paging.Data<DrawCoinList.ResItem[]>> {
  const res = await defaHttp.post<ApiRes<Paging.Data<DrawCoinList.ResItem[]>>>(
    "/money/withdraw",
    data,
    { mode: ["showError"] }
  );
  if (res.code !== 200) return;
  return res.data;
}
/**提币列表 */
export namespace DrawCoinList {
  export interface ResItem {
    id: Id;
    user_id: Id;
    coin_id: Id;
    to: string;
    number: StrNumber;
    actual_number: StrNumber;
    fee: StrNumber;
    status: number;
    txid: string;
    deal_time: string | Date | null;
    created_at: Date | string;
    updated_at: Date | string;
    chainid: number;
    is_check: number;
    old_txid: string | null;
    status_text: string;
    coin: Coin;
  }
}
